import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

//线程池
public class Demo24 {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(4);
        for (int i = 0; i < 1000; ++i) {
            int finalI = i;
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    final int temp = finalI;
                    System.out.println(temp);
                }
            });
        }
    }
}
